home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir30 / heaven_1.zip / DDLIST.LSP < prev    next >
Lisp/Scheme  |  1993-08-29  |  15KB  |  439 lines

  1. ;;========================== Load-time error checking ========================
  2.  
  3.   (defun ai_abort (app msg)
  4.      (defun *error* (s)
  5.         (if old_error (setq *error* old_error))
  6.         (princ)
  7.      )
  8.      (if msg
  9.        (alert (strcat " Application error: "
  10.                       app
  11.                       " \n\n  "
  12.                       msg
  13.                       "  \n"
  14.               )
  15.        )
  16.      )
  17.      (exit)
  18.   )
  19.  
  20. ;;; Check to see if AI_UTILS is loaded, If not, try to find it,
  21. ;;; and then try to load it.
  22. ;;;
  23. ;;; If it can't be found or it can't be loaded, then abort the
  24. ;;; loading of this file immediately, preserving the (autoload)
  25. ;;; stub function.
  26.  
  27.   (cond
  28.      (  (and ai_dcl (listp ai_dcl)))          ; it's already loaded.
  29.  
  30.      (  (not (findfile "ai_utils.lsp"))                     ; find it
  31.         (ai_abort "DDLIST"
  32.                   (strcat "Can't locate file AI_UTILS.LSP."
  33.                           "\n Check support directory.")))
  34.  
  35.      (  (eq "failed" (load "ai_utils" "failed"))            ; load it
  36.         (ai_abort "DDLIST" "Can't load file AI_UTILS.LSP"))
  37.   )
  38.  
  39.   (if (not (ai_acadapp))               ; defined in AI_UTILS.LSP
  40.       (ai_abort "DDLIST" nil)         ; a Nil <msg> supresses
  41.   )                                    ; ai_abort's alert box dialog.
  42.  
  43. ;;======================== End load-time error checking ======================
  44.  
  45. (defun C:DDLIST ()
  46.    (setq *olderror* *error*)
  47.    (defun *error* (msg)
  48.       (princ msg)
  49.       (setq 
  50.          *error* *olderror*
  51.          *olderror* nil
  52.       )
  53.       (princ)
  54.    )
  55.    (ddlist nil)
  56.    (princ)
  57. )   
  58.  
  59. (defun DDLIST 
  60.    (
  61.       ddlist_flag / ddlist_str dxf gc_pts ddlist_ent ddlist_name
  62.       ddlist_etype 
  63.    )
  64.  
  65.    ;;; Point to string conversion
  66.    ;;;
  67.    ;;; Purpose: Takes a point list and converts it to a string. It can
  68.    ;;;          handle 2-D or 3-D points.             
  69.    ;;;
  70.    ;;; Returns: The point as a string utilizing commas as separators.   
  71.    ;;;
  72.    ;;;    Note: No built-in error checking, this expects a valid point list.
  73.  
  74.    (defun gc_pts (pt)
  75.       (strcat
  76.          (rtos (car pt))
  77.          ","
  78.          (rtos (cadr pt))
  79.          (if (/= (caddr pt) nil)
  80.             (strcat
  81.                ","
  82.                (rtos (caddr pt))
  83.             )
  84.             ""
  85.          )   
  86.       )
  87.    )
  88.  
  89.    (defun DXF (code lst) (cdr (assoc code lst)))
  90.    
  91.    (defun ddlist_str (dxfcode)
  92.       (if ddlist_flag
  93.          (if dxfcode
  94.             (strcat
  95.                (substr "   " 1 (- 3 (strlen (itoa dxfcode))))
  96.                "("
  97.                (itoa dxfcode)
  98.                ")"
  99.             )
  100.             "     "
  101.          )
  102.          ""
  103.       )
  104.    )
  105.  
  106.    ;allow selection based on global variable
  107.    (if (= #ddlist_n "1")
  108.       (while (=
  109.             (setq ddlist_ent (nentsel))
  110.             nil
  111.          )
  112.          (prompt "\nNo entity selected.")
  113.       )
  114.       (while (=
  115.             (setq ddlist_ent (entsel))
  116.             nil
  117.          )
  118.          (prompt "\nNo entity selected.")
  119.       )
  120.    )
  121.  
  122.    ;reassign for entity list
  123.    (setq ddlist_ent
  124.       (entget
  125.          (setq ddlist_name (car ddlist_ent))
  126.       )
  127.    )
  128.  
  129.    ;highlight the entity
  130.    (redraw ddlist_name 3)
  131.  
  132.    ;set up the dialog identification
  133.    (setq id (load_dialog "ddlist"))
  134.  
  135.    (new_dialog "ddlist" id "" #ddlist_loc)
  136.  
  137.    ;start the list
  138.    (start_list "list_box")
  139.  
  140.    ;check entity type
  141.    (setq ddlist_etype (dxf 0 ddlist_ent))
  142.  
  143.    ;change insert to block
  144.    (add_list 
  145.       (strcat "        Entity" (ddlist_str 0) ": "
  146.          (if (/= ddlist_etype "INSERT")
  147.             (dxf 0 ddlist_ent)
  148.             "BLOCK"
  149.          )
  150.       )
  151.    )
  152.  
  153.    ;add the common dxf groups
  154.    (add_list (strcat "         Layer" (ddlist_str 8) ": " (dxf 8 ddlist_ent)))
  155.    (add_list
  156.       (strcat "         Color" (ddlist_str 62) ": "
  157.          (if (dxf 62 ddlist_ent)
  158.             (itoa (dxf 62 ddlist_ent))
  159.             "BYLAYER"
  160.          )
  161.       )
  162.    )
  163.    (add_list
  164.       (strcat "     Thickness" (ddlist_str 39) ": "
  165.          (if (dxf 39 ddlist_ent)
  166.             (rtos (dxf 39 ddlist_ent))
  167.             "0"
  168.          )
  169.       )
  170.    )
  171.    (add_list
  172.       (strcat "      Linetype" (ddlist_str 6) ": "
  173.          (if (dxf 6 ddlist_ent)
  174.             (dxf 6 ddlist_ent)
  175.             "BYLAYER"
  176.          )
  177.       )
  178.    )
  179.    (add_list
  180.       (strcat "      Location" (ddlist_str 67) ": "
  181.          (if 
  182.             (or 
  183.                (= (dxf 67 ddlist_ent) nil)
  184.                (= (dxf 67 ddlist_ent) 0)
  185.             )
  186.             "MODEL SPACE"
  187.             "PAPER SPACE"
  188.          )
  189.       )
  190.    )
  191.  
  192.    ;process the dxf groups specific to each entity
  193.    (cond 
  194.       ((or (= ddlist_etype "TRACE") (= ddlist_etype "3DFACE") (= ddlist_etype "SOLID"))
  195.          (add_list (strcat "  First Corner" (ddlist_str 10) ": " (gc_pts (dxf 10 ddlist_ent))))
  196.          (add_list (strcat " Second Corner" (ddlist_str 11) ": " (gc_pts (dxf 11 ddlist_ent))))
  197.          (add_list (strcat "  Third Corner" (ddlist_str 12) ": " (gc_pts (dxf 12 ddlist_ent))))
  198.          (add_list (strcat " Fourth Corner" (ddlist_str 13) ": " (gc_pts (dxf 13 ddlist_ent))))
  199.       )
  200.       ((or (= ddlist_etype "ATTDEF") (= ddlist_etype "ATTRIB"))
  201.          (add_list (strcat "   Start Point" (ddlist_str 10) ": " (gc_pts (dxf 10 ddlist_ent))))
  202.          (add_list (strcat "        Height" (ddlist_str 40) ": " (rtos (dxf 40 ddlist_ent))))
  203.          (add_list (strcat " Default Value" (ddlist_str 1) ": " (dxf 1 ddlist_ent)))
  204.          (if (= ddlist_etype "ATTDEF")
  205.             (add_list (strcat " Prompt String" (ddlist_str 3) ": " (dxf 3 ddlist_ent)))
  206.          )   
  207.          (add_list (strcat "    Tag String" (ddlist_str 2) ": " (dxf 2 ddlist_ent)))
  208.          (add_list
  209.             (strcat "  Field Length" (ddlist_str 73) ": "
  210.                (if (dxf 73 ddlist_ent)
  211.                   (itoa (dxf 73 ddlist_ent))
  212.                   "0"
  213.                )
  214.             )
  215.          )
  216.          (add_list
  217.             (strcat "Rotation Angle" (ddlist_str 50) ": "
  218.                (if (dxf 50 ddlist_ent)
  219.                   (angtos (dxf 50 ddlist_ent))
  220.                   (angtos 0)
  221.                )
  222.             )
  223.          )
  224.          (add_list
  225.             (strcat "X Scale Factor" (ddlist_str 41) ": "  
  226.                (if (dxf 41 ddlist_ent)
  227.                   (rtos (dxf 41 ddlist_ent))
  228.                   (rtos 0)
  229.                )
  230.             )
  231.          )
  232.          (add_list
  233.             (strcat " Oblique angle" (ddlist_str 51) ": "
  234.                (if (dxf 51 ddlist_ent)
  235.                   (angtos (dxf 51 ddlist_ent))  
  236.                   (angtos 0)
  237.                )
  238.             )
  239.          )
  240.          (add_list 
  241.             (strcat "    Text Style" (ddlist_str 7) ": "
  242.                (if (dxf 7 ddlist_ent)
  243.                   (dxf 7 ddlist_ent)
  244.                   "STANDARD"
  245.                )
  246.             )
  247.          )
  248.       )
  249.       ((or (= ddlist_etype "ARC") (= ddlist_etype "CIRCLE"))
  250.          (add_list (strcat "        Center" (ddlist_str 10) ": " (gc_pts (dxf 10 ddlist_ent))))
  251.          (add_list (strcat "        Radius" (ddlist_str 40) ": " (rtos (dxf 40 ddlist_ent))))
  252.          (if (= ddlist_etype "ARC")
  253.             (progn
  254.                (add_list (strcat "   Start Angle" (ddlist_str 50) ": " (angtos (dxf 50 ddlist_ent))))
  255.                (add_list (strcat "     End Angle" (ddlist_str 51) ": " (angtos (dxf 51 ddlist_ent))))
  256.             )
  257.          )
  258.       )
  259.       ((= ddlist_etype "DIMENSION")
  260.          (add_list (strcat "    Block Name" (ddlist_str 2) ": " (dxf 2 ddlist_ent)))
  261.          (add_list (strcat "    Style Name" (ddlist_str 3) ": " (dxf 3 ddlist_ent)))
  262.          (add_list (strcat " Definition Pt" (ddlist_str 10) ": " (gc_pts (dxf 10 ddlist_ent))))
  263.          (add_list (strcat "  Middle Point" (ddlist_str 11) ": " (gc_pts (dxf 11 ddlist_ent))))
  264.          (if (/= (dxf 1 ddlist_ent) "")
  265.             (add_list (strcat "          Text" (ddlist_str 1) ": " (dxf 1 ddlist_ent)))
  266.          )
  267.          (if (dxf 40 ddlist_ent)
  268.             (add_list (strcat " Leader Length" (ddlist_str 40) ": " (rtos (dxf 40 ddlist_ent))))   
  269.          )
  270.          (if (dxf 50 ddlist_ent)
  271.             (add_list (strcat "Rotation Angle" (ddlist_str 50) ": " (angtos (dxf 50 ddlist_ent))))
  272.          )
  273.          (if (dxf 52 ddlist_ent)
  274.             (add_list (strcat "    Ext. Angle" (ddlist_str 52) ": " (angtos (dxf 52 ddlist_ent))))
  275.          )
  276.          (if (dxf 53 ddlist_ent)
  277.             (add_list (strcat "    Text Angle" (ddlist_str 53) ": " (angtos (dxf 53 ddlist_ent))))
  278.          )
  279.  
  280.       )
  281.       ((= ddlist_etype "INSERT")
  282.          (add_list (strcat "    Block Name" (ddlist_str 2) ": " (dxf 2 ddlist_ent)))
  283.          (add_list (strcat "  Insertion Pt" (ddlist_str 10) ": " (gc_pts (dxf 10 ddlist_ent))))
  284.          (if (dxf 41 ddlist_ent)
  285.             (add_list (strcat "X Scale Factor" (ddlist_str 41) ": " (rtos (dxf 41 ddlist_ent))))
  286.          )   
  287.          (if (dxf 42 ddlist_ent)
  288.             (add_list (strcat "Y Scale Factor" (ddlist_str 42) ": " (rtos (dxf 42 ddlist_ent))))
  289.          )   
  290.          (if (dxf 43 ddlist_ent)
  291.             (add_list (strcat "Z Scale Factor" (ddlist_str 43) ": " (rtos (dxf 43 ddlist_ent))))
  292.          )   
  293.          (if (dxf 50 ddlist_ent)
  294.             (add_list (strcat "Rotation Angle" (ddlist_str 50) ": " (angtos (dxf 50 ddlist_ent))))
  295.          )   
  296.          (if (dxf 70 ddlist_ent)
  297.             (add_list (strcat "  Column Count" (ddlist_str 70) ": " (itoa (dxf 70 ddlist_ent))))
  298.          )   
  299.          (if (dxf 71 ddlist_ent)
  300.             (add_list (strcat "     Row Count" (ddlist_str 71) ": " (itoa (dxf 71 ddlist_ent))))
  301.          )   
  302.          (if (dxf 44 ddlist_ent)
  303.             (add_list (strcat "Column Spacing" (ddlist_str 44) ": " (rtos (dxf 44 ddlist_ent))))
  304.          )   
  305.          (if (dxf 45 ddlist_ent)
  306.             (add_list (strcat "   Row Spacing" (ddlist_str 45) ": " (rtos (dxf 45 ddlist_ent))))
  307.          )   
  308.       )
  309.       ((= ddlist_etype "LINE")
  310.          (add_list (strcat "   Start Point" (ddlist_str 10) ": " (gc_pts (dxf 10 ddlist_ent))))
  311.          (add_list (strcat "     End Point" (ddlist_str 11) ": " (gc_pts (dxf 11 ddlist_ent))))
  312.          (add_list
  313.             (strcat "  Angle Formed" (ddlist_str nil) ": "
  314.                (angtos
  315.                   (angle
  316.                      (dxf 10 ddlist_ent)
  317.                      (dxf 11 ddlist_ent)
  318.                   )
  319.                )
  320.             )
  321.          )   
  322.          (add_list
  323.             (strcat "        Length" 
  324.                (ddlist_str nil)
  325.                ": "
  326.                (rtos
  327.                   (distance
  328.                      (dxf 10 ddlist_ent)
  329.                      (dxf 11 ddlist_ent) 
  330.                   )
  331.                )
  332.             )
  333.          )
  334.       )
  335.       ((= ddlist_etype "POINT")
  336.          (add_list (strcat "    Coordinate" (ddlist_str 10) ": " (gc_pts (dxf 10 ddlist_ent))))
  337.          (if (dxf 50 ddlist_ent)
  338.             (add_list (strcat "  X Axis Angle" (ddlist_str 50) ": " (angtos (dxf 50 ddlist_ent))))
  339.          )
  340.       )
  341.       ((= ddlist_etype "POLYLINE")
  342.          (add_list (strcat "     Elevation" (ddlist_str 10) ": " (rtos (caddr (dxf 10 ddlist_ent)))))
  343.          (if (dxf 40 ddlist_ent)
  344.             (add_list (strcat "Starting Width" (ddlist_str 40) ": " (rtos (dxf 40 ddlist_ent))))
  345.          )
  346.          (if (dxf 41 ddlist_ent)
  347.             (add_list (strcat "  Ending Width" (ddlist_str 41) ": " (rtos (dxf 41 ddlist_ent))))
  348.          )
  349.       )
  350.       ((= ddlist_etype "SHAPE")
  351.          (add_list (strcat "  Insertion Pt" (ddlist_str 10) ": " (gc_pts (dxf 10 ddlist_ent))))
  352.          (add_list (strcat "          Size" (ddlist_str 40) ": " (rtos (dxf 40 ddlist_ent))))
  353.          (add_list (strcat "    Shape Name" (ddlist_str 2) ": " (dxf 2 ddlist_ent)))
  354.          (if (dxf 50 ddlist_ent)
  355.             (add_list (strcat "Rotation Angle" (ddlist_str 50) ": " (angtos (dxf 50 ddlist_ent))))
  356.          )
  357.          (if (dxf 41 ddlist_ent)
  358.             (add_list (strcat "X Scale Factor" (ddlist_str 41) ": " (rtos (dxf 41 ddlist_ent))))
  359.          )
  360.          (if (dxf 51 ddlist_ent)
  361.             (add_list (strcat " Oblique Angle" (ddlist_str 51) ": " (angtos (dxf 51 ddlist_ent))))
  362.          )
  363.       )
  364.       ((= ddlist_etype "TEXT")
  365.          (add_list (strcat "  Insertion Pt" (ddlist_str 10) ": " (gc_pts (dxf 10 ddlist_ent))))
  366.          (add_list (strcat "        Height" (ddlist_str 40) ": " (rtos (dxf 40 ddlist_ent))))
  367.          (add_list (strcat "          Text" (ddlist_str 1) ": " (dxf 1 ddlist_ent)))
  368.          (if (dxf 50 ddlist_ent)
  369.             (add_list (strcat "Rotation Angle" (ddlist_str 50) ": " (angtos (dxf 50 ddlist_ent))))
  370.          )
  371.          (if (dxf 41 ddlist_ent)
  372.             (add_list (strcat "X Scale Factor" (ddlist_str 41) ": " (rtos (dxf 41 ddlist_ent))))
  373.          )                                     
  374.          (if (dxf 51 ddlist_ent)
  375.             (add_list (strcat " Oblique Angle" (ddlist_str 51) ": " (angtos (dxf 51 ddlist_ent))))
  376.          )
  377.          (add_list
  378.             (strcat "    Text Style" (ddlist_str 7) ": "
  379.                (if (dxf 7 ddlist_ent)
  380.                   (dxf 7 ddlist_ent)
  381.                   "STANDARD"
  382.                )
  383.             )
  384.          )
  385.       ) 
  386.       ((= ddlist_etype "VERTEX")
  387.          (add_list (strcat "   Location Pt" (ddlist_str 10) ": " (gc_pts (dxf 10 ddlist_ent))))
  388.          (if (dxf 40 ddlist_ent)
  389.             (add_list (strcat "Starting Width" (ddlist_str 40) ": " (rtos (dxf 40 ddlist_ent))))
  390.          )
  391.          (if (dxf 41 ddlist_ent)
  392.             (add_list (strcat "  Ending Width" (ddlist_str 41) ": " (rtos (dxf 41 ddlist_ent))))
  393.          )
  394.          (if (dxf 42 ddlist_ent)
  395.             (add_list (strcat "         Bulge" (ddlist_str 42) ": " (rtos (dxf 42 ddlist_ent))))
  396.          )
  397.       )
  398.       ((= ddlist_etype "VIEWPORT")
  399.          (add_list (strcat "     Center Pt" (ddlist_str 10) ": " (gc_pts (dxf 10 ddlist_ent))))
  400.          (add_list (strcat "         Width" (ddlist_str 40) ": " (rtos (dxf 40 ddlist_ent))))
  401.          (add_list (strcat "        Height" (ddlist_str 41) ": " (rtos (dxf 41 ddlist_ent))))
  402.       )  
  403.    )
  404.  
  405.    ;stop the list box
  406.    (end_list)
  407.  
  408.    ;highlight the nested option if present
  409.    (if (= #ddlist_n "1")
  410.       (set_tile "nested" "1")
  411.    )
  412.  
  413.    ;set the list again to nil
  414.    (setq ddlist_again nil)
  415.  
  416.    (action_tile "accept" "(setq #ddlist_loc (done_dialog))")
  417.    (action_tile "nested" "(setq #ddlist_n $value)")
  418.    (action_tile "again"  "(setq ddlist_again T #ddlist_loc (done_dialog))")
  419.  
  420.    (start_dialog)
  421.    (unload_dialog id)
  422.    (redraw ddlist_name 4)
  423.  
  424.    ;do it again if necessary
  425.    (if ddlist_again
  426.       (if ddlist_flag
  427.          (ddlist T)
  428.          (C:DDLIST)
  429.       )
  430.    )
  431.  
  432.    (setq *error* *olderror*)
  433.  
  434.    (prin1)
  435. )  
  436. (princ "DDLIST Loaded.")
  437. (princ)
  438.  
  439.